<template>
  <el-dialog title="添加工程" :modelValue="visiable" width="30%" @close="emit('closed')">
    <el-form :model="model" label-width="60px" :inline="false">
      <el-form-item label="名称">
        <el-input v-model="model.name">
          <template #prepend>
            <EditName theme="outline" size="18" fill="#333" />
          </template>
        </el-input>
      </el-form-item>
      <el-form-item label="简称">
        <el-input v-model="model.shortName">
          <template #prepend>
            <Merge theme="outline" size="18" fill="#333" />
          </template>
        </el-input>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" @click="onSubmit">立即创建</el-button>
        <el-button @click="emit('closed')">取消</el-button>
      </el-form-item>
    </el-form>
  </el-dialog>
</template>

<script setup lang="ts">
import useProj from '@/composables/useProj'
import { EditName, Merge } from '@icon-park/vue-next'
import { reactive } from 'vue'

defineProps<{ visiable: boolean }>()
const emit = defineEmits(['closed'])

const { add } = useProj()

const model = reactive<ProjModel>({
  name: '皖电东送淮南至上海特高压输电示范工程',
  shortName: '淮上线',
})

async function onSubmit() {
  await add({ ...model })
  emit('closed')
}
</script>

<style></style>
